package com.example.mapper;

import com.example.dto.EmpDto;
import com.example.dto.EmpLoginDto;
import com.example.pojo.Emp;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {


 /*   //未使用插件
    @Select("select * from emp limit #{start},#{pageSize}")
    public List<Emp> getByPage(@Param("start") Integer start, @Param("pageSize")Integer pageSize);

    @Select("select count(*) from emp")
    public Long getTotal();*/
    //使用分页插件
  /*  @Select("select * from emp")
    public List<Emp> getByPage();*/

    List <Emp>getByPage(EmpDto empDto);


    int deleteByIds(@Param("ids") Integer[] ids);

    @Insert("insert into emp values(null,#{username},#{password},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    int insertEmp(Emp emp);

    @Select("select * from emp where id =#{id}")
    Emp selectById(Integer id);

    int updateEmp(Emp emp);


   /* @Select("select * from emp where username=#{username} and #{password}")
    Emp login(Emp emp);*/

    @Select("select * from emp where username=#{username} and #{password}")
    Emp findByusernameAndPassword(EmpLoginDto dto);

    @Delete("delete from emp where dept_id=#{deptId}")
    int delByDeptId(Integer deptId);
}
